package action.schoolyearmgn;

import java.io.File;
import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import model.Student;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import service.YearService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("")
@Action(
	value="importstuexcel",
	results={
			@Result(name="success",location="/WEB-INF/Yearmgn.jsp")
	}		
)
public class addStudentExcel extends ActionSupport{
	 private File file ;
	 private String fileFileName ;
	 private String fileContentType ;
	 private String year;
	public String execute() throws Exception { 
		YearService yearservice=new YearService();
		ArrayList<Student> studentlist=yearservice.importExcel(file,year);
		HttpServletRequest request=ServletActionContext.getRequest();
		ServletContext application=request.getServletContext();
		application.setAttribute("schoolyear", year);
		request.setAttribute("StudentList", studentlist);
		request.setAttribute("importmessage","<script>alert('导入学生信息成功！')</script>" );
		return SUCCESS;
	}
	public File getFile() {
		return file;
	}
	public void setFile(File file) {
		this.file = file;
	}
	public String getFileFileName() {
		return fileFileName;
	}
	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}
	public String getFileContentType() {
		return fileContentType;
	}
	public void setFileContentType(String fileContentType) {
		this.fileContentType = fileContentType;
	}
	public String getYear() {
		return year;
	}
	public void setYear(String year) {
		this.year = year;
	}
}
